//
//  MoreWarMViewC.m
//  WHSport
//
//  Created by ccjoy-jimneylee on 15/5/21.
//  Copyright (c) 2015年 jimneylee. All rights reserved.
//

#import "MoreWarMViewC.h"
#import "UserModel.h"
#import "WarEntity.h"
#import <UIImageView+AFNetworking.h>

@interface MoreWarMCell : UITableViewCell{
    
}
@property (weak, nonatomic) IBOutlet UIImageView *headerImg;
@property (weak, nonatomic) IBOutlet UILabel *nickLab;
@property (weak, nonatomic) IBOutlet UILabel *addressLab;
@property (weak, nonatomic) IBOutlet UILabel *phoneLab;
@end

@implementation  MoreWarMCell
- (void)viewWillDisappear:(BOOL)animated{
    [self viewWillDisappear:YES];
    self.headerImg.layer.cornerRadius = 30;
    self.headerImg.clipsToBounds = YES;
}
@end

@interface MoreWarMViewC (){
    NSArray *dataArray;
}

@end

@implementation MoreWarMViewC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title =@"参战人员";
    [self getData];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)getData{
    
    NSString *num = self.warID;
    [[UserModel sharedInstance] mywarPersonWithwid:num myData:^(id info) {
        NSArray *array = [info copy];
        dataArray = array;
        [self.tableView reloadData];
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 77.f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MoreWarMCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MoreWarMCellID"
                             forIndexPath:indexPath];
    WarEntity *warEty = dataArray[indexPath.row];
    cell.nickLab.text = warEty.wnick;
    cell.addressLab.text = warEty.address;
    cell.phoneLab.text = [NSString stringWithFormat:@"%@",
                          warEty.userPhone];
    NSString *headimg = [NSString stringWithFormat:@"http://218.93.12.178:8080/hhw-api/%@",
                         warEty.wheadpic];
    NSURL *headurl = [NSURL URLWithString:headimg];
    [cell.headerImg setImageWithURL:headurl];
    return cell;
}




@end
